package unitTests;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import javax.swing.JTextField;

import mainpackage.Category;
import mainpackage.DataManager;
import mainpackage.Todo;

import org.junit.Test;

import com.sun.xml.internal.bind.v2.TODO;

import ui.EditTodoPresenter;
import ui.EditTodoWindow;
import ui.MainPresenter;
import ui.MainWindow;

import static org.mockito.Mockito.*;

public class EditTodoTest {
	
	EditTodoWindow mockedEditWindow = mock(EditTodoWindow.class);
	EditTodoPresenter editPresenter = new EditTodoPresenter(mockedEditWindow);
	DataManager mockedDataManager = mock(DataManager.class);

	public EditTodoTest(){
		editPresenter.setDataManager(mockedDataManager);
		editPresenter.setEditableTodo(mock(Todo.class));
		
		when(mockedEditWindow.getTitleField()).thenReturn(new JTextField());
		when(mockedEditWindow.getStartField()).thenReturn(new JTextField());
		when(mockedEditWindow.getEndField()).thenReturn(new JTextField());
	}
	
	@Test
	public void todoIsEdited() throws Exception {
		when(mockedEditWindow.getTodoName()).thenReturn("title");
		when(mockedEditWindow.getTodoDesctiption()).thenReturn("");
		when(mockedEditWindow.getTodoStartTime()).thenReturn("2012/10/10 10:10");
		when(mockedEditWindow.getTodoEndTime()).thenReturn("2012/10/10 10:20");
		when(mockedEditWindow.getTodoCategory()).thenReturn("Work");
		
		editPresenter.saveButtonClicked();
		
		verify(mockedEditWindow).dispose();
		verify(mockedDataManager).editTodo((Todo)any(), (String)any(),(String)any(), (String)any(), (String)any(), (Category)any());
	}
}
